﻿using DataStructure;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace DataStructure.Test
{
    
    
    /// <summary>
    ///This is a test class for MyStacksTest and is intended
    ///to contain all MyStacksTest Unit Tests
    ///</summary>
    [TestClass()]
    public class MyStacksTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for MyStacks Constructor
        ///</summary>
        [TestMethod()]
        public void MyStacksConstructorTest()
        {
            MyStack target = new MyStack();
            Assert.Inconclusive("TODO: Implement code to verify target");
        }

        /// <summary>
        ///A test for push
        ///</summary>
        [TestMethod()]
        public void pushTest()
        {
            MyStack target = new MyStack(); // TODO: Initialize to an appropriate value
            object item = null; // TODO: Initialize to an appropriate value
            target.push(item);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for pop
        ///</summary>
        [TestMethod()]
        public void popTest()
        {
            MyStack target = new MyStack(); // TODO: Initialize to an appropriate value
            object expected = null; // TODO: Initialize to an appropriate value
            object actual;
            actual = target.pop();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for peek
        ///</summary>
        [TestMethod()]
        public void peekTest()
        {
            MyStack alist = new MyStack();
            string ch;
            string word = "sees";
            bool isPalindrome = true;
            for (int x = 0; x < word.Length; x++)
                alist.push(word.Substring(x, 1));

            int pos = 0;
            while (alist.count > 0)
            {
                ch = alist.pop().ToString();
                if (ch != word.Substring(pos, 1))
                {
                    isPalindrome = false;
                    break;
                }
                pos++;
            }
            if (isPalindrome)
                Console.WriteLine(word + "isa palindrome.");
            else
                Console.WriteLine(word + "isnota palindrome.");
            Console.Read();
        }
    }
}
